package com.leetcode.LC;

public class LC263 {
    public boolean isUgly(int num) {

        if (num<=1)
            return (num==1)?true:false;
        while(num>1){
            int t = num;
            while(t%2==0) t/=2;
            while(t%3==0) t/=3;
            while(t%5==0) t/=5;
            if(t == num) return false;
            num = t;
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new LC263().isUgly(8));
    }
}
